const mongoose = require('mongoose');
const { v4: uuidv4 } = require('uuid');
const jobTicketSchema = new mongoose.Schema({
    jobTicketId: { type: String, default: uuidv4 },
    departmentId: { type: mongoose.Schema.Types.ObjectId, ref: 'Department' },
    typeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Type' },
    createTime: { type: Number, default: Date.now() },
    workPlace: { type: String },
    workContent: { type: String },
    workCompany: { type: String },
    workStartTime: { type: Number },
    workEndTime: { type: Number },
    statusId: { type: mongoose.Schema.Types.ObjectId, ref: 'Status' }
});
// 添加复合索引，优化常用查询场景
jobTicketSchema.index({ statusId: 1, typeId: -1 });
jobTicketSchema.index({ workPlace: 1});
module.exports = mongoose.model('JobTicket', jobTicketSchema);
